package TOP101;

/**
 * @Question BM32
 * @Date 2022/11/13 16:00
 * @Solution
 */
public class BM32 {
    public TreeNode mergeTrees (TreeNode t1, TreeNode t2) {
        // write code here
        t1.val=t1.val+t2.val;
        if(t1.left!=null&&t2.left!=null){
            mergeTrees(t1.left,t2.left);
        }
        else if(t1.left==null&&t2.left!=null){
            t1.left=t2.left;
        }
        if(t1.right!=null&&t2.right!=null){
            mergeTrees(t1.right,t2.right);
        }
        else if(t1.right==null&&t2.right!=null){
            t1.right=t2.right;
        }
        return t1;
    }
}
